package com.example.lzl.wuziqi;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Adapter;
import android.widget.Button;

import static com.example.lzl.wuziqi.R.layout.activity_main;

public class MainActivity extends AppCompatActivity {

    private WuziqiPanel wuziqiPanel;
    private Button btn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(activity_main);

        wuziqiPanel=(WuziqiPanel) (findViewById(R.id.action_setting));
        btn=(Button) (findViewById(R.id.button));

        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                wuziqiPanel.restart();
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
        getMenuInflater().inflate(R.menu.menu_main,menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id=item.getItemId();

        if(id==R.id.action_setting){
            wuziqiPanel.restart();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}
